<?php

namespace App\Models\Application;

use Eloquent as Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * Class Apppage
 * @package App\Models\Application
 * @version July 17, 2018, 1:59 pm CST
 *
 * @property \App\Models\Application\Application application
 * @property \App\Models\Application\Pagetpl pagetpl
 * @property string name
 * @property string title
 * @property string subtitle
 * @property integer applciation_id
 * @property string release
 * @property string ui
 * @property integer pagetpl_id
 * @property string description
 */
class Apppage extends Model
{
    use SoftDeletes;

    public $table = 'apppages';

    protected $dates = ['deleted_at'];

    public $fillable = [
        'name',
        'title',
        'subtitle',
        'application_id',
        'release',
        'ui',
        'pagetpl_id',
        'description',
    ];

    /**
     * The attributes that should be casted to native types.
     *
     * @var array
     */
    protected $casts = [
        'name'           => 'string',
        'title'          => 'string',
        'subtitle'       => 'string',
        'application_id' => 'integer',
        'release'        => 'string',
        'ui'             => 'string',
        'pagetpl_id'     => 'integer',
        'description'    => 'string',
    ];

    /**
     * Validation rules
     *
     * @var array
     */
    public static $rules = [
        'name' => 'required|max:100',
    ];

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     **/
    public function application()
    {
        return $this->hasOne(\App\Models\Application\Application::class, 'id', 'application_id');
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     **/
    public function pagetpl()
    {
        return $this->hasOne(\App\Models\Application\Pagetpl::class, 'id', 'pagetpl_id');
    }
}
